﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ElevatorSimCSharp
{
    class Elevator
    {
        short currentFloor;
        short LastFloorToGoTo;
        byte numberOfPeopleInElevator;
        List<Person> peopleGoTo;
        sbyte goingWhichDirection;
        short maxFloor;
        short minFloor;
        byte maxPeopleInElevator;

        public Elevator(short floorStart, short maxFloor, short minFloor, byte maxPeopleInElevator)
        {
            this.currentFloor = floorStart;
            this.goingWhichDirection = 0;
            this.maxFloor = maxFloor;
            this.minFloor = minFloor;
            this.maxPeopleInElevator = maxPeopleInElevator;
        }

        public Elevator()
        {
            peopleGoTo = new List<Person>();
            currentFloor = 0;
            minFloor = 0;
            maxFloor = 0;
            maxPeopleInElevator = 10;

        }

        public List<Person> getPersonsList()
        {
            return peopleGoTo;
        }

        public void setPersonsList(List<Person> peopleList)
        {
            peopleGoTo = peopleList;
        }

        public void addPerson(Person person)
        {
            if (numberOfPeopleInElevator < maxPeopleInElevator)
            {
                peopleGoTo.Add(person);
            }
        }

        public void removePeople()
        {
            foreach (Person person in peopleGoTo)
            {
                if (person.getWantToGoTo() == currentFloor)
                {
                    peopleGoTo.Remove(person);
                }
            }

        }

        public short getCurrentFloor()
        {
            return currentFloor;
        }

        public void initializeElevator(short floorStart, short maxFloor, short minFloor, byte maxPeopleInElevator)
        {
            this.currentFloor = floorStart;
            this.goingWhichDirection = 0;
            this.maxFloor = maxFloor;
            this.minFloor = minFloor;
            this.maxPeopleInElevator = maxPeopleInElevator;
        }

        public sbyte getDirection()
        {
            return goingWhichDirection;
        }

        public byte getMaxNumberOfPeople()
        {
            return maxPeopleInElevator;
        }

        public byte getNumberOfPeopleInElevator()
        {
            return numberOfPeopleInElevator;
        }

        public void incrementNumberOfPeopleInElevator()
        {
            numberOfPeopleInElevator++;
        }

        public void decrementNumberOfPeopleInElevator()
        {
            numberOfPeopleInElevator--;
        }

        public void moveElevator(short speed)
        {
            currentFloor += speed;
        }

        //public void incrementCurrentFloor(short speed)
        //{
        //    currentFloor += speed;
        //}

        //public void decrementCurrentFloor(short speed)
        //{
        //    currentFloor += speed;
        //}

        public short getLastFloorToGoTo()
        {
            return LastFloorToGoTo;
        }

        public void setLastFloorToGoTo(short lastFloorToGoTo)
        {
            this.LastFloorToGoTo = lastFloorToGoTo;
        }

        public void setDirection(sbyte direction)
        {
            this.goingWhichDirection = direction;
        }
    }
}
